<?php

namespace LowCode\Traits\Props;

use LowCode\Support\JsExp;

/**
 * 设置组件是否展示
 */
trait HasShow
{
    /**
     * 设置组件是否展示
     * @param bool|string|JsExp $bool
     * @return $this
     */
    public function show(bool|string|JsExp $bool = true): static
    {
        return $this->setBoolProp('show', $bool);
    }

    /**
     * 设置组件是否展示
     * @param string $value
     * @param string|null $id
     * @param array $options
     * @return $this
     */
    public function vModelShow(string $value, string $id = null, array $options = []): static
    {
        return $this->vModelArg('show', $value, $id, $options);
    }

    /**
     * 面板可见状态改变的回调
     * @param string $event (value: boolean) => void
     * @param string|null $id
     * @param array $modifiers
     * @return $this
     */
    public function onUpdateShow(string $event = "(value) => {}", string $id = null, array $modifiers = []): static
    {
        return $this->event('update:show', jsFn($event, $id), $modifiers);
    }
}
